// 外卖平台数据库系统
// 使用 localStorage 模拟数据库功能

class Database {
    constructor() {
        this.initDatabase();
    }

    // 初始化数据库
    initDatabase() {
        // 检查是否需要重新初始化数据
        const shouldReinit = localStorage.getItem('shouldReinit') === 'true';
        
        // 如果需要重新初始化，清空所有数据
        if (shouldReinit) {
            localStorage.removeItem('users');
            localStorage.removeItem('dishes');
            localStorage.removeItem('orders');
            localStorage.removeItem('merchants');
            localStorage.removeItem('currentUser');
            localStorage.removeItem('shouldReinit');
        }
        
    // 初始化用户数据
        if (!localStorage.getItem('users')) {
            const users = [
            {
                id: 1,
                    username: 'admin',
                    password: '1234',
                    phone: '13800138000',
                    email: 'admin@test.com',
                    type: 'user',
                    name: '管理员',
                    avatar: '👤',
                    registerTime: new Date().toLocaleString()
            },
            {
                id: 2,
                    username: 'merchant1',
                    password: '1234',
                    phone: '13800138001',
                    email: 'merchant@test.com',
                    type: 'merchant',
                    name: '美味餐厅',
                    avatar: '🏪',
                    registerTime: new Date().toLocaleString(),
                    restaurantInfo: {
                        name: '美味餐厅',
                        address: '北京市朝阳区xxx街道123号',
                phone: '010-12345678',
                        description: '正宗川菜，麻辣鲜香',
                rating: 4.8,
                        deliveryTime: '30分钟',
                deliveryFee: 5,
                        minOrder: 20
                    }
            },
            {
                id: 3,
                    username: 'rider1',
                    password: '1234',
                    phone: '13800138002',
                    email: 'rider@test.com',
                    type: 'rider',
                    name: '张师傅',
                    avatar: '🏍️',
                    registerTime: new Date().toLocaleString(),
                    riderInfo: {
                        vehicle: '电动车',
                        license: 'A123456',
                        area: '朝阳区',
                rating: 4.9,
                        completedOrders: 156
                    }
                }
            ];
            localStorage.setItem('users', JSON.stringify(users));
    }

    // 初始化菜品数据
        if (!localStorage.getItem('dishes')) {
            const dishes = [
                // 老街面馆 (merchantId: 2)
                {
                    id: 1,
                    merchantId: 2,
                    name: '招牌牛肉面',
                    price: 22,
                    originalPrice: 25,
                    category: '面条',
                    description: '精选牛腱肉搭配手工面条，汤底浓郁',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 50,
                    cookingTime: 15,
                    tags: ['热卖', '招牌'],
                    ingredients: '牛肉,面条,青菜,香菜',
                    allergens: '无',
                    rating: 4.8,
                    sales: 128,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 2,
                    merchantId: 2,
                    name: '番茄鸡蛋面',
                    price: 16,
                    originalPrice: 18,
                    category: '面条',
                    description: '酸甜可口，营养丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 40,
                    cookingTime: 12,
                    tags: ['推荐'],
                    ingredients: '番茄,鸡蛋,面条,葱花',
                    allergens: '鸡蛋',
                    rating: 4.5,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 3,
                    merchantId: 2,
                    name: '凉拌黄瓜',
                    price: 8,
                    originalPrice: 10,
                    category: '凉菜',
                    description: '清爽解腻',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 30,
                    cookingTime: 5,
                    tags: ['清爽'],
                    ingredients: '黄瓜,蒜,醋,香油',
                    allergens: '无',
                    rating: 4.3,
                    sales: 45,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 4,
                    merchantId: 2,
                    name: '红烧肉面',
                    price: 24,
                    originalPrice: 28,
                    category: '面条',
                    description: '肥瘦相间的红烧肉，配手工面条',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 35,
                    cookingTime: 18,
                    tags: ['招牌'],
                    ingredients: '五花肉,面条,青菜,香料',
                    allergens: '无',
                    rating: 4.6,
                    sales: 76,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 5,
                    merchantId: 2,
                    name: '酸辣粉',
                    price: 14,
                    originalPrice: 16,
                    category: '面条',
                    description: '酸辣开胃，粉条Q弹',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 45,
                    cookingTime: 10,
                    tags: ['酸辣'],
                    ingredients: '粉条,酸菜,辣椒,花生',
                    allergens: '花生',
                    rating: 4.4,
                    sales: 95,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 6,
                    merchantId: 2,
                    name: '炸酱面',
                    price: 18,
                    originalPrice: 20,
                    category: '面条',
                    description: '传统炸酱，配黄瓜丝',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 50,
                    cookingTime: 12,
                    tags: ['传统'],
                    ingredients: '面条,炸酱,黄瓜丝,豆芽',
                    allergens: '大豆',
                    rating: 4.5,
                    sales: 112,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 7,
                    merchantId: 2,
                    name: '担担面',
                    price: 20,
                    originalPrice: 22,
                    category: '面条',
                    description: '四川传统，麻辣鲜香',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 40,
                    cookingTime: 15,
                    tags: ['麻辣'],
                    ingredients: '面条,肉末,花生,辣椒',
                    allergens: '花生',
                    rating: 4.7,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 8,
                    merchantId: 2,
                    name: '葱油拌面',
                    price: 12,
                    originalPrice: 14,
                    category: '面条',
                    description: '简单美味，葱香浓郁',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 60,
                    cookingTime: 8,
                    tags: ['经济'],
                    ingredients: '面条,葱花,香油,生抽',
                    allergens: '无',
                    rating: 4.2,
                    sales: 78,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 9,
                    merchantId: 2,
                    name: '鸡丝凉面',
                    price: 16,
                    originalPrice: 18,
                    category: '面条',
                    description: '清爽凉面，配鸡丝黄瓜',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 35,
                    cookingTime: 10,
                    tags: ['清爽'],
                    ingredients: '面条,鸡丝,黄瓜,芝麻酱',
                    allergens: '芝麻',
                    rating: 4.4,
                    sales: 56,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 10,
                    merchantId: 2,
                    name: '牛肉汤',
                    price: 15,
                    originalPrice: 18,
                    category: '汤品',
                    description: '清汤牛肉，营养丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 25,
                    cookingTime: 20,
                    tags: ['营养'],
                    ingredients: '牛肉,萝卜,香菜,香料',
                    allergens: '无',
                    rating: 4.6,
                    sales: 43,
                    createTime: new Date().toLocaleString()
                },
                
                // 披萨小屋 (merchantId: 3)
                {
                    id: 11,
                    merchantId: 3,
                    name: '超级至尊披萨',
                    price: 68,
                    originalPrice: 78,
                    category: '披萨',
                    description: '多种肉类和蔬菜搭配',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['热卖', '折扣'],
                    ingredients: '芝士,香肠,培根,青椒,洋葱',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 95,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 12,
                    merchantId: 3,
                    name: '海鲜披萨',
                    price: 58,
                    originalPrice: 65,
                    category: '披萨',
                    description: '新鲜海鲜，口感丰富',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 15,
                    cookingTime: 30,
                    tags: ['海鲜'],
                    ingredients: '芝士,虾,鱿鱼,青椒,洋葱',
                    allergens: '海鲜,乳制品',
                    rating: 4.5,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 13,
                    merchantId: 3,
                    name: '玛格丽特披萨',
                    price: 38,
                    originalPrice: 42,
                    category: '披萨',
                    description: '经典意式，番茄芝士',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 20,
                    tags: ['经典'],
                    ingredients: '芝士,番茄,罗勒,橄榄油',
                    allergens: '乳制品',
                    rating: 4.7,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 14,
                    merchantId: 3,
                    name: '夏威夷披萨',
                    price: 45,
                    originalPrice: 50,
                    category: '披萨',
                    description: '火腿菠萝，甜咸搭配',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 25,
                    cookingTime: 22,
                    tags: ['甜咸'],
                    ingredients: '芝士,火腿,菠萝,洋葱',
                    allergens: '乳制品',
                    rating: 4.4,
                    sales: 54,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 15,
                    merchantId: 3,
                    name: '意式香肠披萨',
                    price: 52,
                    originalPrice: 58,
                    category: '披萨',
                    description: '正宗意式香肠，口感丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['意式'],
                    ingredients: '芝士,意式香肠,青椒,洋葱',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 71,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 16,
                    merchantId: 3,
                    name: '素食披萨',
                    price: 42,
                    originalPrice: 48,
                    category: '披萨',
                    description: '多种蔬菜，健康美味',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 18,
                    cookingTime: 20,
                    tags: ['素食'],
                    ingredients: '芝士,蘑菇,青椒,洋葱,番茄',
                    allergens: '乳制品',
                    rating: 4.3,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 17,
                    merchantId: 3,
                    name: '芝士披萨',
                    price: 35,
                    originalPrice: 40,
                    category: '披萨',
                    description: '纯芝士，奶香浓郁',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 35,
                    cookingTime: 18,
                    tags: ['芝士'],
                    ingredients: '芝士,番茄酱,香料',
                    allergens: '乳制品',
                    rating: 4.5,
                    sales: 62,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 18,
                    merchantId: 3,
                    name: '辣味香肠披萨',
                    price: 48,
                    originalPrice: 55,
                    category: '披萨',
                    description: '辣味香肠，刺激味蕾',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 22,
                    cookingTime: 25,
                    tags: ['辣味'],
                    ingredients: '芝士,辣香肠,青椒,洋葱',
                    allergens: '乳制品',
                    rating: 4.4,
                    sales: 49,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 19,
                    merchantId: 3,
                    name: '四芝士披萨',
                    price: 55,
                    originalPrice: 62,
                    category: '披萨',
                    description: '四种芝士混合，层次丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 15,
                    cookingTime: 28,
                    tags: ['芝士'],
                    ingredients: '马苏里拉,切达,帕玛森,蓝纹芝士',
                    allergens: '乳制品',
                    rating: 4.8,
                    sales: 33,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 20,
                    merchantId: 3,
                    name: '鸡肉BBQ披萨',
                    price: 50,
                    originalPrice: 56,
                    category: '披萨',
                    description: 'BBQ鸡肉，甜辣口味',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 20,
                    cookingTime: 24,
                    tags: ['BBQ'],
                    ingredients: '芝士,BBQ鸡肉,洋葱,青椒',
                    allergens: '乳制品',
                    rating: 4.5,
                    sales: 41,
                    createTime: new Date().toLocaleString()
                },
                
                // 川味小厨 (merchantId: 4)
                {
                    id: 21,
                    merchantId: 4,
                    name: '宫保鸡丁',
                    price: 28,
                    originalPrice: 32,
                    category: '川菜',
                    description: '经典川菜，鸡肉嫩滑，花生香脆，麻辣鲜香',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 50,
                    cookingTime: 15,
                    tags: ['辣', '推荐', '热销'],
                    ingredients: '鸡肉,花生,干辣椒,花椒,葱,姜,蒜',
                    allergens: '花生',
                    rating: 4.7,
                    sales: 128,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 22,
                    merchantId: 4,
                    name: '麻婆豆腐',
                    price: 22,
                    originalPrice: 26,
                    category: '川菜',
                    description: '嫩滑豆腐配麻辣调料，口感丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['辣', '素食'],
                    ingredients: '豆腐,猪肉末,豆瓣酱,花椒,葱,姜',
                    allergens: '大豆',
                    rating: 4.5,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 23,
                    merchantId: 4,
                    name: '回锅肉',
                    price: 35,
                    originalPrice: 40,
                    category: '川菜',
                    description: '肥瘦相间的五花肉，配青椒炒制',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 25,
                    cookingTime: 18,
                    tags: ['辣', '推荐'],
                    ingredients: '五花肉,青椒,豆瓣酱,甜面酱,葱,姜,蒜',
                    allergens: '无',
                    rating: 4.6,
                    sales: 76,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 24,
                    merchantId: 4,
                    name: '水煮鱼',
                    price: 48,
                    originalPrice: 55,
                    category: '川菜',
                    description: '鲜嫩鱼肉，麻辣汤底，配菜丰富',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['辣', '热销'],
                    ingredients: '草鱼,豆芽,白菜,干辣椒,花椒,葱,姜',
                    allergens: '鱼类',
                    rating: 4.8,
                    sales: 95,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 25,
                    merchantId: 4,
                    name: '蒜蓉西兰花',
                    price: 18,
                    originalPrice: 20,
                    category: '素菜',
                    description: '清爽素菜，蒜香浓郁，营养丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 40,
                    cookingTime: 8,
                    tags: ['素食', '健康'],
                    ingredients: '西兰花,大蒜,盐,鸡精',
                    allergens: '无',
                    rating: 4.3,
                    sales: 45,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 26,
                    merchantId: 4,
                    name: '蛋炒饭',
                    price: 15,
                    originalPrice: 18,
                    category: '主食',
                    description: '粒粒分明的米饭，配鸡蛋炒制',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 60,
                    cookingTime: 10,
                    tags: ['推荐', '经济'],
                    ingredients: '米饭,鸡蛋,葱花,盐,生抽',
                    allergens: '鸡蛋',
                    rating: 4.4,
                    sales: 112,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 27,
                    merchantId: 4,
                    name: '口水鸡',
                    price: 32,
                    originalPrice: 36,
                    category: '川菜',
                    description: '麻辣鲜香，鸡肉嫩滑',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 35,
                    cookingTime: 20,
                    tags: ['辣', '招牌'],
                    ingredients: '鸡肉,花生,芝麻,辣椒油,花椒',
                    allergens: '花生,芝麻',
                    rating: 4.6,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 28,
                    merchantId: 4,
                    name: '酸辣土豆丝',
                    price: 12,
                    originalPrice: 14,
                    category: '素菜',
                    description: '酸辣开胃，口感爽脆',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 50,
                    cookingTime: 8,
                    tags: ['酸辣', '经济'],
                    ingredients: '土豆,青椒,醋,辣椒',
                    allergens: '无',
                    rating: 4.2,
                    sales: 78,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 29,
                    merchantId: 4,
                    name: '辣子鸡',
                    price: 38,
                    originalPrice: 42,
                    category: '川菜',
                    description: '麻辣干香，鸡肉外酥内嫩',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 22,
                    tags: ['辣', '热销'],
                    ingredients: '鸡肉,干辣椒,花椒,花生,芝麻',
                    allergens: '花生,芝麻',
                    rating: 4.7,
                    sales: 56,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 30,
                    merchantId: 4,
                    name: '蒜泥白肉',
                    price: 28,
                    originalPrice: 32,
                    category: '川菜',
                    description: '肥瘦相间，蒜香浓郁',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 25,
                    cookingTime: 15,
                    tags: ['蒜香'],
                    ingredients: '五花肉,大蒜,生抽,香油',
                    allergens: '无',
                    rating: 4.4,
                    sales: 43,
                    createTime: new Date().toLocaleString()
                },
                
                // 日式料理 (merchantId: 5)
                {
                    id: 31,
                    merchantId: 5,
                    name: '三文鱼刺身',
                    price: 68,
                    originalPrice: 75,
                    category: '刺身',
                    description: '新鲜三文鱼，口感嫩滑',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 15,
                    cookingTime: 5,
                    tags: ['新鲜', '招牌'],
                    ingredients: '三文鱼,芥末,酱油',
                    allergens: '鱼类',
                    rating: 4.9,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 32,
                    merchantId: 5,
                    name: '寿司拼盘',
                    price: 88,
                    originalPrice: 98,
                    category: '寿司',
                    description: '多种寿司组合，精致美味',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 12,
                    cookingTime: 20,
                    tags: ['精致', '推荐'],
                    ingredients: '米饭,三文鱼,金枪鱼,虾,海苔',
                    allergens: '海鲜,大米',
                    rating: 4.8,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 33,
                    merchantId: 5,
                    name: '天妇罗',
                    price: 45,
                    originalPrice: 50,
                    category: '炸物',
                    description: '酥脆外皮，内里鲜嫩',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 20,
                    cookingTime: 15,
                    tags: ['酥脆'],
                    ingredients: '虾,蔬菜,天妇罗粉,油',
                    allergens: '海鲜',
                    rating: 4.6,
                    sales: 54,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 34,
                    merchantId: 5,
                    name: '日式拉面',
                    price: 38,
                    originalPrice: 42,
                    category: '面条',
                    description: '浓郁汤底，配菜丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['浓郁'],
                    ingredients: '拉面,叉烧,海苔,鸡蛋,豆芽',
                    allergens: '鸡蛋,大豆',
                    rating: 4.5,
                    sales: 71,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 35,
                    merchantId: 5,
                    name: '照烧鸡排',
                    price: 42,
                    originalPrice: 48,
                    category: '主菜',
                    description: '日式照烧汁，鸡肉嫩滑',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 25,
                    cookingTime: 18,
                    tags: ['照烧'],
                    ingredients: '鸡胸肉,照烧汁,芝麻',
                    allergens: '芝麻',
                    rating: 4.7,
                    sales: 62,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 36,
                    merchantId: 5,
                    name: '日式煎饺',
                    price: 28,
                    originalPrice: 32,
                    category: '小食',
                    description: '底部酥脆，内馅鲜美',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 40,
                    cookingTime: 10,
                    tags: ['酥脆'],
                    ingredients: '饺子皮,猪肉,韭菜,香油',
                    allergens: '无',
                    rating: 4.4,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 37,
                    merchantId: 5,
                    name: '味噌汤',
                    price: 18,
                    originalPrice: 20,
                    category: '汤品',
                    description: '日式传统汤品，营养丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 35,
                    cookingTime: 8,
                    tags: ['传统'],
                    ingredients: '味噌,豆腐,海带,葱花',
                    allergens: '大豆',
                    rating: 4.3,
                    sales: 45,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 38,
                    merchantId: 5,
                    name: '日式炒饭',
                    price: 32,
                    originalPrice: 36,
                    category: '主食',
                    description: '粒粒分明，配菜丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['推荐'],
                    ingredients: '米饭,鸡蛋,虾,青豆,胡萝卜',
                    allergens: '鸡蛋,海鲜',
                    rating: 4.5,
                    sales: 56,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 39,
                    merchantId: 5,
                    name: '日式沙拉',
                    price: 25,
                    originalPrice: 28,
                    category: '沙拉',
                    description: '清爽蔬菜，日式调味',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 25,
                    cookingTime: 5,
                    tags: ['清爽'],
                    ingredients: '生菜,黄瓜,番茄,日式酱汁',
                    allergens: '无',
                    rating: 4.2,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 40,
                    merchantId: 5,
                    name: '日式茶碗蒸',
                    price: 22,
                    originalPrice: 25,
                    category: '蒸品',
                    description: '嫩滑蒸蛋，配菜丰富',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 20,
                    cookingTime: 15,
                    tags: ['嫩滑'],
                    ingredients: '鸡蛋,虾,香菇,高汤',
                    allergens: '鸡蛋,海鲜',
                    rating: 4.6,
                    sales: 33,
                    createTime: new Date().toLocaleString()
                },
                
                // 韩式烤肉 (merchantId: 6)
                {
                    id: 41,
                    merchantId: 6,
                    name: '韩式烤肉',
                    price: 58,
                    originalPrice: 65,
                    category: '烤肉',
                    description: '正宗韩式烤肉，配菜丰富',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['招牌', '热卖'],
                    ingredients: '牛肉,韩式调料,生菜,蒜片',
                    allergens: '无',
                    rating: 4.5,
                    sales: 95,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 42,
                    merchantId: 6,
                    name: '韩式泡菜',
                    price: 15,
                    originalPrice: 18,
                    category: '小菜',
                    description: '酸辣开胃，韩式传统',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 40,
                    cookingTime: 5,
                    tags: ['传统'],
                    ingredients: '白菜,辣椒粉,蒜,姜',
                    allergens: '无',
                    rating: 4.3,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 43,
                    merchantId: 6,
                    name: '韩式拌饭',
                    price: 32,
                    originalPrice: 36,
                    category: '主食',
                    description: '营养丰富，色彩缤纷',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 15,
                    tags: ['营养'],
                    ingredients: '米饭,蔬菜,鸡蛋,韩式辣酱',
                    allergens: '鸡蛋',
                    rating: 4.4,
                    sales: 54,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 44,
                    merchantId: 6,
                    name: '韩式炸鸡',
                    price: 38,
                    originalPrice: 42,
                    category: '炸物',
                    description: '外酥内嫩，韩式调味',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 25,
                    cookingTime: 20,
                    tags: ['酥脆'],
                    ingredients: '鸡肉,韩式调料,面粉',
                    allergens: '无',
                    rating: 4.6,
                    sales: 71,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 45,
                    merchantId: 6,
                    name: '韩式冷面',
                    price: 28,
                    originalPrice: 32,
                    category: '面条',
                    description: '清爽冷面，夏日首选',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 35,
                    cookingTime: 10,
                    tags: ['清爽'],
                    ingredients: '冷面,黄瓜,鸡蛋,韩式汤底',
                    allergens: '鸡蛋',
                    rating: 4.5,
                    sales: 62,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 46,
                    merchantId: 6,
                    name: '韩式年糕',
                    price: 22,
                    originalPrice: 25,
                    category: '小食',
                    description: 'Q弹年糕，韩式辣酱',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['Q弹'],
                    ingredients: '年糕,韩式辣酱,鱼饼,洋葱',
                    allergens: '无',
                    rating: 4.4,
                    sales: 48,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 47,
                    merchantId: 6,
                    name: '韩式汤',
                    price: 25,
                    originalPrice: 28,
                    category: '汤品',
                    description: '韩式传统汤品，营养丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 25,
                    cookingTime: 18,
                    tags: ['传统'],
                    ingredients: '韩式汤底,蔬菜,豆腐',
                    allergens: '大豆',
                    rating: 4.3,
                    sales: 36,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 48,
                    merchantId: 6,
                    name: '韩式煎饼',
                    price: 18,
                    originalPrice: 20,
                    category: '小食',
                    description: '香脆煎饼，配菜丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 40,
                    cookingTime: 15,
                    tags: ['香脆'],
                    ingredients: '面粉,蔬菜,鸡蛋,韩式调料',
                    allergens: '鸡蛋',
                    rating: 4.2,
                    sales: 42,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 49,
                    merchantId: 6,
                    name: '韩式蒸蛋',
                    price: 20,
                    originalPrice: 22,
                    category: '蒸品',
                    description: '嫩滑蒸蛋，韩式调味',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['嫩滑'],
                    ingredients: '鸡蛋,韩式调料,葱花',
                    allergens: '鸡蛋',
                    rating: 4.4,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 50,
                    merchantId: 6,
                    name: '韩式沙拉',
                    price: 16,
                    originalPrice: 18,
                    category: '沙拉',
                    description: '清爽蔬菜，韩式调味',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 35,
                    cookingTime: 5,
                    tags: ['清爽'],
                    ingredients: '生菜,黄瓜,韩式酱汁',
                    allergens: '无',
                    rating: 4.1,
                    sales: 29,
                    createTime: new Date().toLocaleString()
                },
                
                // 粤式茶餐厅 (merchantId: 7)
                {
                    id: 51,
                    merchantId: 7,
                    name: '白切鸡',
                    price: 42,
                    originalPrice: 48,
                    category: '粤菜',
                    description: '嫩滑鸡肉，清淡鲜美',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 25,
                    cookingTime: 30,
                    tags: ['招牌', '清淡'],
                    ingredients: '鸡肉,姜,葱,生抽',
                    allergens: '无',
                    rating: 4.6,
                    sales: 78,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 52,
                    merchantId: 7,
                    name: '叉烧包',
                    price: 8,
                    originalPrice: 10,
                    category: '点心',
                    description: '香甜叉烧，松软包子',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 50,
                    cookingTime: 8,
                    tags: ['点心'],
                    ingredients: '面粉,叉烧,糖,酵母',
                    allergens: '无',
                    rating: 4.5,
                    sales: 125,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 53,
                    merchantId: 7,
                    name: '虾饺',
                    price: 15,
                    originalPrice: 18,
                    category: '点心',
                    description: '晶莹剔透，虾肉鲜美',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 40,
                    cookingTime: 10,
                    tags: ['招牌'],
                    ingredients: '虾,澄面,竹笋,香油',
                    allergens: '海鲜',
                    rating: 4.7,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 54,
                    merchantId: 7,
                    name: '烧卖',
                    price: 12,
                    originalPrice: 15,
                    category: '点心',
                    description: '传统烧卖，肉香浓郁',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 45,
                    cookingTime: 12,
                    tags: ['传统'],
                    ingredients: '猪肉,虾,香菇,烧卖皮',
                    allergens: '海鲜',
                    rating: 4.4,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 55,
                    merchantId: 7,
                    name: '白粥',
                    price: 6,
                    originalPrice: 8,
                    category: '粥品',
                    description: '清淡白粥，养胃佳品',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 60,
                    cookingTime: 20,
                    tags: ['清淡'],
                    ingredients: '大米,水',
                    allergens: '大米',
                    rating: 4.2,
                    sales: 95,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 56,
                    merchantId: 7,
                    name: '肠粉',
                    price: 18,
                    originalPrice: 22,
                    category: '点心',
                    description: '滑嫩肠粉，配菜丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 35,
                    cookingTime: 15,
                    tags: ['滑嫩'],
                    ingredients: '米浆,虾,牛肉,青菜',
                    allergens: '海鲜',
                    rating: 4.5,
                    sales: 54,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 57,
                    merchantId: 7,
                    name: '凤爪',
                    price: 22,
                    originalPrice: 25,
                    category: '点心',
                    description: '软糯凤爪，酱香浓郁',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 30,
                    cookingTime: 25,
                    tags: ['软糯'],
                    ingredients: '鸡爪,豆豉,蒜,辣椒',
                    allergens: '无',
                    rating: 4.3,
                    sales: 41,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 58,
                    merchantId: 7,
                    name: '萝卜糕',
                    price: 16,
                    originalPrice: 18,
                    category: '点心',
                    description: '香煎萝卜糕，外酥内软',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 25,
                    cookingTime: 20,
                    tags: ['香煎'],
                    ingredients: '萝卜,米粉,腊肠,虾米',
                    allergens: '海鲜',
                    rating: 4.4,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 59,
                    merchantId: 7,
                    name: '蛋挞',
                    price: 10,
                    originalPrice: 12,
                    category: '甜品',
                    description: '酥脆蛋挞，香甜可口',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 40,
                    cookingTime: 15,
                    tags: ['酥脆'],
                    ingredients: '面粉,鸡蛋,牛奶,糖',
                    allergens: '鸡蛋,乳制品',
                    rating: 4.6,
                    sales: 72,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 60,
                    merchantId: 7,
                    name: '奶茶',
                    price: 12,
                    originalPrice: 15,
                    category: '饮品',
                    description: '香浓奶茶，港式经典',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 50,
                    cookingTime: 5,
                    tags: ['经典'],
                    ingredients: '红茶,牛奶,糖',
                    allergens: '乳制品',
                    rating: 4.5,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                
                // 汉堡王 (merchantId: 8)
                {
                    id: 61,
                    merchantId: 8,
                    name: '经典汉堡',
                    price: 25,
                    originalPrice: 28,
                    category: '汉堡',
                    description: '经典美式汉堡，牛肉饼配蔬菜',
                    image: 'https://picsum.photos/id/225/200/200',
                    stock: 50,
                    cookingTime: 8,
                    tags: ['经典', '热卖'],
                    ingredients: '牛肉饼,生菜,番茄,洋葱,芝士',
                    allergens: '乳制品',
                    rating: 4.3,
                    sales: 145,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 62,
                    merchantId: 8,
                    name: '芝士汉堡',
                    price: 28,
                    originalPrice: 32,
                    category: '汉堡',
                    description: '双层芝士，奶香浓郁',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 40,
                    cookingTime: 10,
                    tags: ['芝士'],
                    ingredients: '牛肉饼,芝士,生菜,番茄',
                    allergens: '乳制品',
                    rating: 4.4,
                    sales: 98,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 63,
                    merchantId: 8,
                    name: '炸鸡汉堡',
                    price: 22,
                    originalPrice: 25,
                    category: '汉堡',
                    description: '酥脆炸鸡，配蔬菜',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 35,
                    cookingTime: 12,
                    tags: ['酥脆'],
                    ingredients: '炸鸡,生菜,番茄,蛋黄酱',
                    allergens: '鸡蛋',
                    rating: 4.2,
                    sales: 76,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 64,
                    merchantId: 8,
                    name: '薯条',
                    price: 12,
                    originalPrice: 15,
                    category: '小食',
                    description: '金黄薯条，外酥内软',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 60,
                    cookingTime: 5,
                    tags: ['经典'],
                    ingredients: '土豆,盐,油',
                    allergens: '无',
                    rating: 4.5,
                    sales: 189,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 65,
                    merchantId: 8,
                    name: '鸡块',
                    price: 18,
                    originalPrice: 20,
                    category: '小食',
                    description: '嫩滑鸡块，配蘸酱',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 45,
                    cookingTime: 8,
                    tags: ['嫩滑'],
                    ingredients: '鸡肉,面粉,调料',
                    allergens: '无',
                    rating: 4.3,
                    sales: 112,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 66,
                    merchantId: 8,
                    name: '可乐',
                    price: 8,
                    originalPrice: 10,
                    category: '饮品',
                    description: '冰爽可乐，解腻首选',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 80,
                    cookingTime: 2,
                    tags: ['冰爽'],
                    ingredients: '可乐,冰块',
                    allergens: '无',
                    rating: 4.1,
                    sales: 234,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 67,
                    merchantId: 8,
                    name: '冰淇淋',
                    price: 15,
                    originalPrice: 18,
                    category: '甜品',
                    description: '香甜冰淇淋，夏日必备',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 30,
                    cookingTime: 3,
                    tags: ['香甜'],
                    ingredients: '牛奶,糖,香草',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 68,
                    merchantId: 8,
                    name: '沙拉',
                    price: 20,
                    originalPrice: 22,
                    category: '沙拉',
                    description: '新鲜蔬菜，健康选择',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 25,
                    cookingTime: 5,
                    tags: ['健康'],
                    ingredients: '生菜,番茄,黄瓜,沙拉酱',
                    allergens: '鸡蛋',
                    rating: 4.2,
                    sales: 43,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 69,
                    merchantId: 8,
                    name: '洋葱圈',
                    price: 16,
                    originalPrice: 18,
                    category: '小食',
                    description: '酥脆洋葱圈，香脆可口',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 35,
                    cookingTime: 6,
                    tags: ['酥脆'],
                    ingredients: '洋葱,面粉,调料',
                    allergens: '无',
                    rating: 4.4,
                    sales: 58,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 70,
                    merchantId: 8,
                    name: '奶昔',
                    price: 18,
                    originalPrice: 20,
                    category: '饮品',
                    description: '香浓奶昔，口感顺滑',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 20,
                    cookingTime: 5,
                    tags: ['香浓'],
                    ingredients: '牛奶,冰淇淋,糖',
                    allergens: '乳制品',
                    rating: 4.5,
                    sales: 41,
                    createTime: new Date().toLocaleString()
                },
                
                // 泰式餐厅 (merchantId: 9)
                {
                    id: 71,
                    merchantId: 9,
                    name: '泰式冬阴功汤',
                    price: 38,
                    originalPrice: 42,
                    category: '汤品',
                    description: '酸辣开胃，泰式经典',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 25,
                    cookingTime: 20,
                    tags: ['酸辣', '招牌'],
                    ingredients: '虾,柠檬草,辣椒,椰奶',
                    allergens: '海鲜,乳制品',
                    rating: 4.4,
                    sales: 78,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 72,
                    merchantId: 9,
                    name: '泰式炒河粉',
                    price: 32,
                    originalPrice: 36,
                    category: '主食',
                    description: '泰式炒粉，配菜丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 15,
                    tags: ['推荐'],
                    ingredients: '河粉,虾,豆芽,花生,柠檬',
                    allergens: '海鲜,花生',
                    rating: 4.5,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 73,
                    merchantId: 9,
                    name: '泰式绿咖喱',
                    price: 42,
                    originalPrice: 48,
                    category: '咖喱',
                    description: '香浓绿咖喱，配米饭',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['香浓'],
                    ingredients: '鸡肉,绿咖喱,椰奶,蔬菜',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 56,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 74,
                    merchantId: 9,
                    name: '泰式沙拉',
                    price: 28,
                    originalPrice: 32,
                    category: '沙拉',
                    description: '清爽泰式沙拉，酸辣开胃',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 25,
                    cookingTime: 8,
                    tags: ['清爽'],
                    ingredients: '青木瓜,胡萝卜,花生,柠檬',
                    allergens: '花生',
                    rating: 4.3,
                    sales: 45,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 75,
                    merchantId: 9,
                    name: '泰式炸春卷',
                    price: 22,
                    originalPrice: 25,
                    category: '小食',
                    description: '酥脆春卷，配蘸酱',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 35,
                    cookingTime: 12,
                    tags: ['酥脆'],
                    ingredients: '春卷皮,蔬菜,虾,泰式蘸酱',
                    allergens: '海鲜',
                    rating: 4.4,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 76,
                    merchantId: 9,
                    name: '泰式奶茶',
                    price: 15,
                    originalPrice: 18,
                    category: '饮品',
                    description: '香浓泰式奶茶，甜而不腻',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 40,
                    cookingTime: 5,
                    tags: ['香浓'],
                    ingredients: '红茶,炼乳,糖,香料',
                    allergens: '乳制品',
                    rating: 4.5,
                    sales: 92,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 77,
                    merchantId: 9,
                    name: '泰式芒果糯米饭',
                    price: 25,
                    originalPrice: 28,
                    category: '甜品',
                    description: '香甜芒果，软糯米饭',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 20,
                    cookingTime: 10,
                    tags: ['香甜'],
                    ingredients: '芒果,糯米,椰奶,糖',
                    allergens: '乳制品',
                    rating: 4.7,
                    sales: 34,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 78,
                    merchantId: 9,
                    name: '泰式烤鸡',
                    price: 35,
                    originalPrice: 40,
                    category: '主菜',
                    description: '香烤鸡肉，泰式调味',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 25,
                    cookingTime: 30,
                    tags: ['香烤'],
                    ingredients: '鸡肉,泰式调料,柠檬,香草',
                    allergens: '无',
                    rating: 4.5,
                    sales: 48,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 79,
                    merchantId: 9,
                    name: '泰式炒饭',
                    price: 28,
                    originalPrice: 32,
                    category: '主食',
                    description: '粒粒分明，配菜丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 12,
                    tags: ['推荐'],
                    ingredients: '米饭,虾,鸡蛋,蔬菜,泰式调料',
                    allergens: '海鲜,鸡蛋',
                    rating: 4.4,
                    sales: 61,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 80,
                    merchantId: 9,
                    name: '泰式椰汁鸡汤',
                    price: 32,
                    originalPrice: 36,
                    category: '汤品',
                    description: '香浓椰汁，鸡肉嫩滑',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 20,
                    cookingTime: 18,
                    tags: ['香浓'],
                    ingredients: '鸡肉,椰奶,柠檬草,香茅',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 39,
                    createTime: new Date().toLocaleString()
                },
                
                // 素食餐厅 (merchantId: 10)
                {
                    id: 81,
                    merchantId: 10,
                    name: '素食汉堡',
                    price: 28,
                    originalPrice: 32,
                    category: '汉堡',
                    description: '纯素汉堡，营养丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 10,
                    tags: ['素食', '健康'],
                    ingredients: '素肉饼,生菜,番茄,洋葱',
                    allergens: '大豆',
                    rating: 4.7,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 82,
                    merchantId: 10,
                    name: '素食沙拉',
                    price: 22,
                    originalPrice: 25,
                    category: '沙拉',
                    description: '新鲜蔬菜，营养均衡',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 40,
                    cookingTime: 5,
                    tags: ['新鲜', '健康'],
                    ingredients: '生菜,番茄,黄瓜,胡萝卜,坚果',
                    allergens: '坚果',
                    rating: 4.5,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 83,
                    merchantId: 10,
                    name: '素食炒饭',
                    price: 25,
                    originalPrice: 28,
                    category: '主食',
                    description: '粒粒分明，配菜丰富',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 35,
                    cookingTime: 12,
                    tags: ['推荐'],
                    ingredients: '米饭,蔬菜,豆腐,香菇',
                    allergens: '大豆',
                    rating: 4.4,
                    sales: 56,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 84,
                    merchantId: 10,
                    name: '素食汤',
                    price: 18,
                    originalPrice: 20,
                    category: '汤品',
                    description: '清淡汤品，营养丰富',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 30,
                    cookingTime: 15,
                    tags: ['清淡'],
                    ingredients: '蔬菜,豆腐,香菇,海带',
                    allergens: '无',
                    rating: 4.3,
                    sales: 42,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 85,
                    merchantId: 10,
                    name: '素食面条',
                    price: 20,
                    originalPrice: 22,
                    category: '面条',
                    description: '手工面条，配菜丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 25,
                    cookingTime: 10,
                    tags: ['手工'],
                    ingredients: '面条,蔬菜,豆腐,香菇',
                    allergens: '小麦',
                    rating: 4.4,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 86,
                    merchantId: 10,
                    name: '素食寿司',
                    price: 32,
                    originalPrice: 36,
                    category: '寿司',
                    description: '精致素食寿司，健康美味',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 20,
                    cookingTime: 15,
                    tags: ['精致'],
                    ingredients: '米饭,蔬菜,海苔,醋',
                    allergens: '大米',
                    rating: 4.6,
                    sales: 29,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 87,
                    merchantId: 10,
                    name: '素食披萨',
                    price: 35,
                    originalPrice: 40,
                    category: '披萨',
                    description: '纯素披萨，芝士浓郁',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 18,
                    cookingTime: 20,
                    tags: ['芝士'],
                    ingredients: '素芝士,蔬菜,番茄酱',
                    allergens: '大豆',
                    rating: 4.5,
                    sales: 34,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 88,
                    merchantId: 10,
                    name: '素食甜品',
                    price: 15,
                    originalPrice: 18,
                    category: '甜品',
                    description: '纯素甜品，香甜可口',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 25,
                    cookingTime: 8,
                    tags: ['香甜'],
                    ingredients: '椰奶,糖,水果,坚果',
                    allergens: '坚果',
                    rating: 4.6,
                    sales: 41,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 89,
                    merchantId: 10,
                    name: '素食果汁',
                    price: 12,
                    originalPrice: 15,
                    category: '饮品',
                    description: '新鲜果汁，营养丰富',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 35,
                    cookingTime: 3,
                    tags: ['新鲜'],
                    ingredients: '水果,水,糖',
                    allergens: '无',
                    rating: 4.4,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 90,
                    merchantId: 10,
                    name: '素食小食',
                    price: 18,
                    originalPrice: 20,
                    category: '小食',
                    description: '健康小食，营养丰富',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 30,
                    cookingTime: 8,
                    tags: ['健康'],
                    ingredients: '蔬菜,坚果,调料',
                    allergens: '坚果',
                    rating: 4.3,
                    sales: 28,
                    createTime: new Date().toLocaleString()
                },
                
                // 甜品工坊 (merchantId: 11)
                {
                    id: 91,
                    merchantId: 11,
                    name: '提拉米苏',
                    price: 35,
                    originalPrice: 40,
                    category: '蛋糕',
                    description: '经典意式甜品，层次丰富',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 15,
                    cookingTime: 30,
                    tags: ['经典', '招牌'],
                    ingredients: '马斯卡彭,咖啡,手指饼,可可粉',
                    allergens: '鸡蛋,乳制品',
                    rating: 4.8,
                    sales: 89,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 92,
                    merchantId: 11,
                    name: '芝士蛋糕',
                    price: 32,
                    originalPrice: 36,
                    category: '蛋糕',
                    description: '浓郁芝士，口感顺滑',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 20,
                    cookingTime: 25,
                    tags: ['浓郁'],
                    ingredients: '芝士,鸡蛋,糖,饼干底',
                    allergens: '鸡蛋,乳制品',
                    rating: 4.7,
                    sales: 76,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 93,
                    merchantId: 11,
                    name: '巧克力蛋糕',
                    price: 38,
                    originalPrice: 42,
                    category: '蛋糕',
                    description: '浓郁巧克力，甜蜜享受',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 18,
                    cookingTime: 35,
                    tags: ['浓郁'],
                    ingredients: '巧克力,面粉,鸡蛋,糖',
                    allergens: '鸡蛋,小麦',
                    rating: 4.6,
                    sales: 67,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 94,
                    merchantId: 11,
                    name: '马卡龙',
                    price: 25,
                    originalPrice: 28,
                    category: '小食',
                    description: '精致马卡龙，色彩缤纷',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 30,
                    cookingTime: 20,
                    tags: ['精致'],
                    ingredients: '杏仁粉,糖,蛋白,色素',
                    allergens: '鸡蛋,坚果',
                    rating: 4.5,
                    sales: 54,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 95,
                    merchantId: 11,
                    name: '布丁',
                    price: 18,
                    originalPrice: 20,
                    category: '布丁',
                    description: '嫩滑布丁，香甜可口',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 40,
                    cookingTime: 15,
                    tags: ['嫩滑'],
                    ingredients: '牛奶,鸡蛋,糖,香草',
                    allergens: '鸡蛋,乳制品',
                    rating: 4.4,
                    sales: 78,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 96,
                    merchantId: 11,
                    name: '冰淇淋',
                    price: 22,
                    originalPrice: 25,
                    category: '冰淇淋',
                    description: '手工冰淇淋，口感顺滑',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 25,
                    cookingTime: 5,
                    tags: ['手工'],
                    ingredients: '牛奶,糖,香草,奶油',
                    allergens: '乳制品',
                    rating: 4.6,
                    sales: 92,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 97,
                    merchantId: 11,
                    name: '泡芙',
                    price: 15,
                    originalPrice: 18,
                    category: '小食',
                    description: '酥脆泡芙，内馅香甜',
                    image: 'https://picsum.photos/id/139/200/200',
                    stock: 35,
                    cookingTime: 12,
                    tags: ['酥脆'],
                    ingredients: '面粉,鸡蛋,奶油,糖',
                    allergens: '鸡蛋,乳制品',
                    rating: 4.5,
                    sales: 63,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 98,
                    merchantId: 11,
                    name: '慕斯',
                    price: 28,
                    originalPrice: 32,
                    category: '慕斯',
                    description: '轻盈慕斯，口感顺滑',
                    image: 'https://picsum.photos/id/431/200/200',
                    stock: 20,
                    cookingTime: 18,
                    tags: ['轻盈'],
                    ingredients: '奶油,糖,吉利丁,水果',
                    allergens: '乳制品',
                    rating: 4.7,
                    sales: 45,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 99,
                    merchantId: 11,
                    name: '曲奇饼干',
                    price: 12,
                    originalPrice: 15,
                    category: '饼干',
                    description: '香脆曲奇，手工制作',
                    image: 'https://picsum.photos/id/1080/200/200',
                    stock: 50,
                    cookingTime: 10,
                    tags: ['香脆'],
                    ingredients: '面粉,黄油,糖,鸡蛋',
                    allergens: '鸡蛋,乳制品,小麦',
                    rating: 4.3,
                    sales: 112,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 100,
                    merchantId: 11,
                    name: '水果塔',
                    price: 30,
                    originalPrice: 35,
                    category: '塔类',
                    description: '新鲜水果，酥脆塔底',
                    image: 'https://picsum.photos/id/292/200/200',
                    stock: 15,
                    cookingTime: 20,
                    tags: ['新鲜'],
                    ingredients: '水果,塔皮,奶油,糖',
                    allergens: '乳制品,小麦',
                    rating: 4.6,
                    sales: 38,
                    createTime: new Date().toLocaleString()
                }
            ];
            localStorage.setItem('dishes', JSON.stringify(dishes));
    }

    // 初始化订单数据
        if (!localStorage.getItem('orders')) {
            const orders = [
            {
                    id: 1001,
                userId: 1,
                    merchantId: 2,
                riderId: null,
                    dishes: [
                        { id: 1, name: '宫保鸡丁', price: 28, quantity: 1 },
                        { id: 6, name: '蛋炒饭', price: 15, quantity: 1 }
                    ],
                    totalPrice: 43,
                    deliveryFee: 5,
                    finalPrice: 48,
                status: 'pending',
                    riderStatus: 'available',
                    orderTime: new Date().toLocaleString(),
                    deliveryAddress: '北京市朝阳区xxx小区1号楼2单元301',
                    customerPhone: '13800138000',
                customerName: '张三',
                    notes: '请送到门口',
                    estimatedTime: 30
                },
                {
                    id: 1002,
                    userId: 1,
                merchantId: 2,
                    riderId: 3,
                    dishes: [
                        { id: 2, name: '麻婆豆腐', price: 22, quantity: 1 },
                        { id: 5, name: '蒜蓉西兰花', price: 18, quantity: 1 }
                    ],
                    totalPrice: 40,
                    deliveryFee: 5,
                    finalPrice: 45,
                    status: 'delivering',
                    riderStatus: 'delivering',
                    orderTime: new Date(Date.now() - 15 * 60000).toLocaleString(),
                    deliveryAddress: '北京市朝阳区xxx小区2号楼1单元201',
                    customerPhone: '13800138000',
                customerName: '李四',
                    notes: '请敲门',
                    estimatedTime: 25,
                    riderName: '张师傅'
                }
            ];
            localStorage.setItem('orders', JSON.stringify(orders));
        }

        // 初始化商家数据
        if (!localStorage.getItem('merchants')) {
            const merchants = [
                {
                    id: 2,
                    name: '老街面馆',
                    type: '中餐',
                    address: '北京市朝阳区xxx街道123号',
                    phone: '010-12345678',
                    description: '传统手工面条，汤底浓郁，配菜丰富',
                    image: 'https://picsum.photos/id/292/300/200',
                    rating: 4.8,
                    deliveryTime: '25-35分钟',
                    deliveryFee: 3,
                    minOrder: 15,
                    openTime: '09:00-22:00',
                    isOpen: true,
                    tags: ['中餐', '面条', '传统'],
                    sales: 1256,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 3,
                    name: '披萨小屋',
                    type: '西餐',
                    address: '北京市朝阳区xxx街道456号',
                    phone: '010-12345679',
                    description: '正宗意式披萨，手工制作，芝士浓郁',
                    image: 'https://picsum.photos/id/225/300/200',
                    rating: 4.6,
                    deliveryTime: '30-45分钟',
                    deliveryFee: 5,
                    minOrder: 30,
                    openTime: '10:00-23:00',
                    isOpen: true,
                    tags: ['西餐', '披萨', '意式'],
                    sales: 892,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 4,
                    name: '川味小厨',
                    type: '川菜',
                    address: '北京市朝阳区xxx街道789号',
                    phone: '010-12345680',
                    description: '正宗川菜，麻辣鲜香，传承经典',
                    image: 'https://picsum.photos/id/431/300/200',
                    rating: 4.7,
                    deliveryTime: '25-40分钟',
                    deliveryFee: 4,
                    minOrder: 25,
                    openTime: '09:00-22:30',
                    isOpen: true,
                    tags: ['川菜', '麻辣', '正宗'],
                    sales: 1156,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 5,
                    name: '日式料理',
                    type: '日料',
                    address: '北京市朝阳区xxx街道101号',
                    phone: '010-12345681',
                    description: '新鲜刺身，精致寿司，日式料理',
                    image: 'https://picsum.photos/id/1080/300/200',
                    rating: 4.9,
                    deliveryTime: '35-50分钟',
                    deliveryFee: 8,
                    minOrder: 50,
                    openTime: '11:00-21:30',
                    isOpen: true,
                    tags: ['日料', '刺身', '寿司'],
                    sales: 634,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 6,
                    name: '韩式烤肉',
                    type: '韩料',
                    address: '北京市朝阳区xxx街道202号',
                    phone: '010-12345682',
                    description: '正宗韩式烤肉，配菜丰富，口感独特',
                    image: 'https://picsum.photos/id/139/300/200',
                    rating: 4.5,
                    deliveryTime: '30-45分钟',
                    deliveryFee: 6,
                    minOrder: 35,
                    openTime: '10:30-22:00',
                    isOpen: true,
                    tags: ['韩料', '烤肉', '泡菜'],
                    sales: 743,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 7,
                    name: '粤式茶餐厅',
                    type: '粤菜',
                    address: '北京市朝阳区xxx街道303号',
                    phone: '010-12345683',
                    description: '正宗粤菜，清淡鲜美，茶点丰富',
                    image: 'https://picsum.photos/id/292/300/200',
                    rating: 4.6,
                    deliveryTime: '25-35分钟',
                    deliveryFee: 4,
                    minOrder: 20,
                    openTime: '08:00-22:00',
                    isOpen: true,
                    tags: ['粤菜', '茶点', '清淡'],
                    sales: 987,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 8,
                    name: '汉堡王',
                    type: '快餐',
                    address: '北京市朝阳区xxx街道404号',
                    phone: '010-12345684',
                    description: '美式汉堡，薯条炸鸡，快餐首选',
                    image: 'https://picsum.photos/id/225/300/200',
                    rating: 4.3,
                    deliveryTime: '20-30分钟',
                    deliveryFee: 3,
                    minOrder: 18,
                    openTime: '07:00-24:00',
                    isOpen: true,
                    tags: ['快餐', '汉堡', '炸鸡'],
                    sales: 1456,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 9,
                    name: '泰式餐厅',
                    type: '东南亚',
                    address: '北京市朝阳区xxx街道505号',
                    phone: '010-12345685',
                    description: '正宗泰式料理，酸辣开胃，香料丰富',
                    image: 'https://picsum.photos/id/431/300/200',
                    rating: 4.4,
                    deliveryTime: '30-40分钟',
                    deliveryFee: 5,
                    minOrder: 28,
                    openTime: '11:00-22:00',
                    isOpen: true,
                    tags: ['泰式', '酸辣', '香料'],
                    sales: 567,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 10,
                    name: '素食餐厅',
                    type: '素食',
                    address: '北京市朝阳区xxx街道606号',
                    phone: '010-12345686',
                    description: '健康素食，营养均衡，绿色环保',
                    image: 'https://picsum.photos/id/1080/300/200',
                    rating: 4.7,
                    deliveryTime: '25-35分钟',
                    deliveryFee: 3,
                    minOrder: 22,
                    openTime: '09:00-21:00',
                    isOpen: true,
                    tags: ['素食', '健康', '环保'],
                    sales: 423,
                    createTime: new Date().toLocaleString()
                },
                {
                    id: 11,
                    name: '甜品工坊',
                    type: '甜品',
                    address: '北京市朝阳区xxx街道707号',
                    phone: '010-12345687',
                    description: '精致甜品，手工制作，甜蜜享受',
                    image: 'https://picsum.photos/id/139/300/200',
                    rating: 4.8,
                    deliveryTime: '20-30分钟',
                    deliveryFee: 4,
                    minOrder: 25,
                    openTime: '10:00-23:00',
                    isOpen: true,
                    tags: ['甜品', '手工', '精致'],
                    sales: 789,
                    createTime: new Date().toLocaleString()
                }
            ];
            localStorage.setItem('merchants', JSON.stringify(merchants));
        }
    }

    // 用户相关操作
    getUsers() {
        return JSON.parse(localStorage.getItem('users') || '[]');
    }

    getUserById(id) {
        const users = this.getUsers();
        return users.find(user => user.id === id);
    }

    getUserByUsername(username) {
        const users = this.getUsers();
        return users.find(user => user.username === username);
    }

    addUser(user) {
        const users = this.getUsers();
        user.id = this.getNextId(users);
        user.registerTime = new Date().toLocaleString();
        users.push(user);
        localStorage.setItem('users', JSON.stringify(users));
        return user;
    }

    updateUser(id, updates) {
        const users = this.getUsers();
        const index = users.findIndex(user => user.id === id);
        if (index !== -1) {
            users[index] = { ...users[index], ...updates };
            localStorage.setItem('users', JSON.stringify(users));
            return users[index];
        }
        return null;
    }

    // 菜品相关操作
    getDishes() {
        return JSON.parse(localStorage.getItem('dishes') || '[]');
    }

    getDishesByMerchant(merchantId) {
        const dishes = this.getDishes();
        return dishes.filter(dish => dish.merchantId === merchantId);
    }

    getDishById(id) {
        const dishes = this.getDishes();
        return dishes.find(dish => dish.id === id);
    }

    addDish(dish) {
        const dishes = this.getDishes();
        dish.id = this.getNextId(dishes);
        dish.createTime = new Date().toLocaleString();
        dishes.push(dish);
        localStorage.setItem('dishes', JSON.stringify(dishes));
        return dish;
    }

    updateDish(id, updates) {
        const dishes = this.getDishes();
        const index = dishes.findIndex(dish => dish.id === id);
        if (index !== -1) {
            dishes[index] = { ...dishes[index], ...updates };
            localStorage.setItem('dishes', JSON.stringify(dishes));
            return dishes[index];
        }
        return null;
    }

    deleteDish(id) {
        const dishes = this.getDishes();
        const filteredDishes = dishes.filter(dish => dish.id !== id);
        localStorage.setItem('dishes', JSON.stringify(filteredDishes));
        return true;
    }

    // 订单相关操作
    getOrders() {
        return JSON.parse(localStorage.getItem('orders') || '[]');
    }

    getOrdersByUser(userId) {
        const orders = this.getOrders();
        return orders.filter(order => order.userId === userId);
    }

    getOrdersByMerchant(merchantId) {
        const orders = this.getOrders();
        return orders.filter(order => order.merchantId === merchantId);
    }

    getOrdersByRider(riderId) {
        const orders = this.getOrders();
        return orders.filter(order => order.riderId === riderId);
    }

    getAvailableOrders() {
        const orders = this.getOrders();
        return orders.filter(order => order.riderStatus === 'available');
    }

    getOrderById(id) {
        const orders = this.getOrders();
        return orders.find(order => order.id === id);
    }

    addOrder(order) {
        const orders = this.getOrders();
        order.id = this.getNextId(orders);
        order.orderTime = new Date().toLocaleString();
        order.status = 'pending';
        order.riderStatus = 'available';
        orders.push(order);
        localStorage.setItem('orders', JSON.stringify(orders));
        return order;
    }

    updateOrder(id, updates) {
        const orders = this.getOrders();
        const index = orders.findIndex(order => order.id === id);
        if (index !== -1) {
            orders[index] = { ...orders[index], ...updates };
            localStorage.setItem('orders', JSON.stringify(orders));
            return orders[index];
        }
        return null;
    }

    // 商家相关操作
    getMerchants() {
        return JSON.parse(localStorage.getItem('merchants') || '[]');
    }

    getMerchantById(id) {
        const merchants = this.getMerchants();
        return merchants.find(merchant => merchant.id === id);
    }

    // 工具方法
    getNextId(items) {
        if (items.length === 0) return 1;
        return Math.max(...items.map(item => item.id)) + 1;
    }

    // 清空所有数据
    clearAllData() {
        localStorage.removeItem('users');
        localStorage.removeItem('dishes');
        localStorage.removeItem('orders');
        localStorage.removeItem('merchants');
        localStorage.removeItem('currentUser');
        this.initDatabase();
    }
    
    // 强制重新初始化数据
    forceReinit() {
        localStorage.setItem('shouldReinit', 'true');
        this.clearAllData();
    }

    // 导出数据
    exportData() {
        return {
            users: this.getUsers(),
            dishes: this.getDishes(),
            orders: this.getOrders(),
            merchants: this.getMerchants()
        };
    }

    // 导入数据
    importData(data) {
        if (data.users) localStorage.setItem('users', JSON.stringify(data.users));
        if (data.dishes) localStorage.setItem('dishes', JSON.stringify(data.dishes));
        if (data.orders) localStorage.setItem('orders', JSON.stringify(data.orders));
        if (data.merchants) localStorage.setItem('merchants', JSON.stringify(data.merchants));
    }
}

// 创建全局数据库实例
window.db = new Database();

// 导出数据库类
if (typeof module !== 'undefined' && module.exports) {
    module.exports = Database;
}